using System;
using GameFramework.Fsm;
using GameFramework.Procedure;

/// <summary>
/// 版本更新检测
/// </summary>
public class CheckVersionProcedure : GameBaseProcedure
{
    private int versionCheckFlag = -1;
    protected override void OnEnter(IFsm<IProcedureManager> procedureOwner)
    {
        base.OnEnter(procedureOwner);
        
        //本地测试阶段，直接走 0模式
        versionCheckFlag = 0;
    }

    protected override void OnNewUpdate(IFsm<IProcedureManager> procedureOwner, float elapseSeconds, float realElapseSeconds)
    {
        base.OnNewUpdate(procedureOwner, elapseSeconds, realElapseSeconds);

        if (versionCheckFlag == -1)
            return;
        
        switch (versionCheckFlag)
        {
            case  0:     //已经是最新
                ChangeState<ResourceInitLoadProcedure>(procedureOwner);
                break;
            case 1:      //更新资源 
                ChangeState<ResourceUpdateProcedure>(procedureOwner);
                break;
            case 2:      //需要更新大版本
                break;
            default:
                throw new Exception($"Checkversion occured unknow exceiption,error code is {versionCheckFlag}");
        }
    }
}